package com.kifas.service;

import java.util.Date;
import java.util.List;

import com.kifas.entity.AkunMasterEntity;
import com.kifas.entity.BarangEntity;
import com.kifas.entity.BukuHutangEntity;
import com.kifas.entity.BukuPiutangEntity;
import com.kifas.entity.BukuVoucherEntity;
import com.kifas.entity.CustomerEntity;
import com.kifas.entity.GroupEntity;
import com.kifas.entity.GudangEntity;
import com.kifas.entity.HutangEntity;
import com.kifas.entity.JenisBarangEntity;
import com.kifas.entity.JenisCustomerEntity;
import com.kifas.entity.KontrakEntity;
import com.kifas.entity.KontrakPembelianEntity;
import com.kifas.entity.MenuEntity;
import com.kifas.entity.PembelianDetailEntity;
import com.kifas.entity.PembelianEntity;
import com.kifas.entity.PenerimaanDetailEntity;
import com.kifas.entity.PenerimaanEntity;
import com.kifas.entity.PengirimanEntity;
import com.kifas.entity.PenjualanDetailEntity;
import com.kifas.entity.PenjualanEntity;
import com.kifas.entity.PiutangEntity;
import com.kifas.entity.ReferenceNumberingEntity;
import com.kifas.entity.SalesEntity;
import com.kifas.entity.SatuanEntity;
import com.kifas.entity.StokOpnameEntity;
import com.kifas.entity.SupplierEntity;
import com.kifas.entity.TransactionJurnalUmumEntity;
import com.kifas.entity.TransactionStokEntity;
import com.kifas.entity.TypeAkunEntity;
import com.kifas.entity.UserEntity;


public interface EntityServiceManager {

	/*
     * ReferenceNumber
     */
	public String getReference(Integer unit, String prefix);
	
	public void persist(ReferenceNumberingEntity referenceNumbering) throws Exception;
	
	/*
	 * Menu
	 */
	public List<MenuEntity> getMenusByGroupId(Long idGroup);
	
	public void persist(MenuEntity menu) throws Exception;
	
	/*
	 * Group
	 */
	public GroupEntity getGroupById(Long id) ;
	
	public void persist(GroupEntity group) throws Exception;
	
	public List<GroupEntity> getGroups();
	
	/*
	 * User
	 */
	
	public UserEntity getUser(String username);
	
	public void persist(UserEntity user) throws Exception;
	
	public boolean getUserValidation(String username, String password);
	
	public void update(UserEntity user) throws Exception;
	
	public List<UserEntity> getUsers();
	
    /*
      * Customer
      */
    public CustomerEntity getCustomer(Long id);

    public List<CustomerEntity> getCustomers();
    
    public void persist(CustomerEntity customer) throws Exception;
    
    public void update(CustomerEntity customer) throws Exception;

    /*
      * Sales
      */
    public SalesEntity getSales(Long id);

    public List<SalesEntity> getSales();
    
    public void persist(SalesEntity sales) throws Exception;
    
    public void update(SalesEntity sales) throws Exception;
    

    /*
      * Barang
      */
    public BarangEntity getBarang(Long id);

    public List<BarangEntity> getBarangs();
    
    public void persist(BarangEntity barang) throws Exception;
    
    public void update(BarangEntity barang) throws Exception;
    
    /*
      * Satuan
      */
    public SatuanEntity getSatuan(Long id);
    
    public List<SatuanEntity> getSatuans();

    public List<SatuanEntity> getSatuans(BarangEntity barang);
    
    public void persist(SatuanEntity satuan) throws Exception;
    
    public void update(SatuanEntity satuan) throws Exception;

    /*
     * StokOpname
     */
    public StokOpnameEntity getStokOpname(Long id);

    public List<StokOpnameEntity> getStokOpnames();
    
    public List<StokOpnameEntity> getStokOpnameAvailable();
    
    public List<StokOpnameEntity> getStokOpnameAvailable(BarangEntity barang);

    public List<StokOpnameEntity> getStokOpnameAvailable(GudangEntity gudangEntity);
    
    public List<StokOpnameEntity> getStokOpnameByBarang(BarangEntity barangEntity);

    public List<StokOpnameEntity> getStokOpnameByGudang(GudangEntity gudangEntity);
    
    public List<StokOpnameEntity> getExpiredStok();
    
    public List<StokOpnameEntity> getExpiredStokByBarang(BarangEntity barangEntity);
    
    public void persist(StokOpnameEntity stokOpnameEntity) throws Exception;
    
    public void populateTodayStok() throws Exception;
    
    
    /*
     * Jenis Barang
     */
    public List<JenisBarangEntity> getJenisBarangs();
    
    public JenisBarangEntity getJenisBarang(Long idJenisBarang);
    
    public void persist(JenisBarangEntity jenisBarang) throws Exception;
    
    public void update(JenisBarangEntity jenisBarang) throws Exception;

    /*
      * Pengiriman
      */

    public List<PengirimanEntity> getPengirimans();

    public PengirimanEntity getPengirimanById(Long id);
    
    public PengirimanEntity getLatestPengirimanByIdPenjualan(Long idPenjualan);

    public List<PengirimanEntity> getPengirimanByIdPenjualans(List<Long> idPenjualans);

    public List<PengirimanEntity> getPengirimanByIdPenjualan(Long idPenjualan);

    public List<PengirimanEntity> getPengirimansByDate(Date startDate, Date endDate);

    public List<PengirimanEntity> getUnreceivedPengirimans();

    public List<PengirimanEntity> getReceivedPengirimans();

    public void persist(PengirimanEntity pengiriman) throws Exception;
    

    /*
      * Penjualan
      */
    public void persist(PenjualanEntity penjualan) throws Exception;

    public void updatePenjualanToClosed(Long idPenjualan) throws Exception;
    
    public PenjualanEntity getPenjualan(Long idPenjualan);
    
    public List<PenjualanEntity> getPenjualans(Date start, Date end);

    public List<PenjualanEntity> getPenjualansJthTempo(Date start);

    public List<PenjualanEntity> getPenjualans(Date start, Date end, boolean sentStatus);

    public List<PenjualanEntity> getPenjualans();

    public List<PenjualanEntity> getPenjualansIsClosed(boolean isClosed);

    public List<PenjualanEntity> getPenjualans(List<Long> idPenjualans);

    public List<PenjualanEntity> getPenjualans(CustomerEntity customer);

    public List<PenjualanEntity> getPenjualans(SalesEntity sales);

    public List<PenjualanEntity> getUnsentPenjualans();
    
	public List<PenjualanDetailEntity> getPenjualanDetailEntities(PenjualanEntity penjualan);
    
    public List<PenjualanEntity> getPenjualanAndDetails();
    
    public List<PenjualanEntity> getPenjualanAndDetails(Date startDate, Date endDate);
    
    /*
	 * Kontrak
	 */
    public List<KontrakEntity> getKontraks();
    
    public List<KontrakEntity> getKontraks(SupplierEntity supplier);

    public List<KontrakPembelianEntity> getKontrakPembelians(KontrakEntity kontrak);
    
    public KontrakEntity getKontrak(Long idKontrak);
    
    public void persist(KontrakEntity kontrak) throws Exception;
    
    public void updateKontrakPembelianToClosed(Long idKontrakPembelian) throws Exception;
    
    /*
	 * Penerimaan
	 */
    public List<PenerimaanEntity> getPenerimaans();
    
    public List<PenerimaanDetailEntity> getPenerimaanDetails(PenerimaanEntity penerimaan);
    
    public PenerimaanEntity getPenerimaan(Long idPenerimaan);
    
    public void persist(PenerimaanEntity penerimaan) throws Exception;
    
    /*
	 * Pembelian
	 */
    public List<PembelianEntity> getPembelians();
    
    public List<PembelianDetailEntity> getPembelianDetails(PembelianEntity pembelian);
    
    public PembelianEntity getPembelian(Long idPembelian);
    
    public List<PembelianEntity> getOpenPembelian();
    
    public List<PembelianEntity> getClosedPembelian();
    
    public void persist(PembelianEntity pembelian) throws Exception;
    
    public void updatePembelianToClosed(Long idPembelian) throws Exception;

    /*
	 * Supplier
	 */
    
    public List<SupplierEntity> getSuppliers();
    
    public SupplierEntity getSupplier(Long idSupplier);
    
    public void persist(SupplierEntity supplier) throws Exception;
    
    public void update(SupplierEntity supplier) throws Exception;
    
	/*
	 * Gudang
	 */
    public GudangEntity getGudang(Long idMasterGudang);

    public List<GudangEntity> getGudangs();

    public void persist(GudangEntity gudang) throws Exception;
    
    public void update(GudangEntity gudang) throws Exception;
    
    /*
     * Transaction Stok
     */
    public boolean isTransactionStokByReferenceExist(String reference);
    
    public List<TransactionStokEntity> getCurrentMonthTransactionStoks();

    
    /*
     * Jenis Customer
     */
    public List<JenisCustomerEntity> getJenisCustomers();
    
	public JenisCustomerEntity getJenisCustomer(Long idJenisCustomer);
	
	public void persist(JenisCustomerEntity jenisCustomer) throws Exception;
	
	public void update(JenisCustomerEntity jenisCustomer) throws Exception;
	
	/*
     * Piutang
     */
	public List<PiutangEntity> getPiutangs();
	
	public List<PiutangEntity> getPiutangs(Date start, Date end);
	
	public PiutangEntity getPiutang(Long idPiutang);
	
    public List<PiutangEntity> getPiutangByNoRef(String noref);
    
    public void markBukuPiutangAsPost(Long idBukuPiutang) throws Exception;
	
	public List<BukuPiutangEntity> getBukuPiutangs(PiutangEntity piutang);
	
	public List<BukuPiutangEntity> getBukuPiutangs(boolean posting);
	
	public BukuPiutangEntity getLatestBukuPiutang(PiutangEntity piutang);
	
	public void persist(PiutangEntity piutang) throws Exception;
	
	public void update(PiutangEntity piutang) throws Exception;
	
	public void persist(BukuPiutangEntity bukuPiutang) throws Exception;
	
	public List<PiutangEntity> getPiutangs(CustomerEntity customer);
	
	public List<PiutangEntity> getPiutangs(int days);
	
	/*
     * Hutang
     */
	public List<HutangEntity> getHutangs();
	
	public List<HutangEntity> getHutangs(Date start, Date end);
	
	public HutangEntity getHutang(Long idHutang);
	
	public List<BukuHutangEntity> getBukuHutangs(HutangEntity hutang);
	
	public List<BukuHutangEntity> getBukuHutangs(boolean posting);
	
	public void persist(HutangEntity hutang) throws Exception;
	
	public void update(HutangEntity hutang) throws Exception;
	
	public void persist(BukuHutangEntity bukuHutang) throws Exception;
	
	public BukuHutangEntity getLatestBukuHutang(HutangEntity hutang);
	
	public List<HutangEntity> getHutangs(SupplierEntity supplier);
	
	public List<HutangEntity> getHutangs(int days);
	
	public void markBukuHutangAsPost(Long idBukuHutang) throws Exception;
	
	/*
     * Type akun
     */
	public List<TypeAkunEntity> getTypeAkuns();
	
	public TypeAkunEntity getTypeAkun(Long idTypeAkun);
	
	public void persist(TypeAkunEntity typeAkun) throws Exception;
	
	public void update(TypeAkunEntity typeAkun) throws Exception;
	
	/*
     * Buku voucher
     */
	public List<BukuVoucherEntity> getBukuVouchers();
	
	public BukuVoucherEntity getBukuVoucher(Long idBukuVoucher);
	
	public void persist(BukuVoucherEntity bukuVoucher) throws Exception;
	
	public void update(BukuVoucherEntity bukuVoucher) throws Exception;
	
	public void markBukuVoucherAsPost(Long idBukuVoucher) throws Exception;
	
	/*
     * Akun Master
     */
	
	public List<AkunMasterEntity> getAkunMasters();
	
	public AkunMasterEntity getAkunMaster(String kdAkun);
	
	public void persist(AkunMasterEntity akunMasterEntity) throws Exception;
	
	public void update(AkunMasterEntity akunMasterEntity) throws Exception;
	
	public List<AkunMasterEntity> getAkunLeaf();

	public List<AkunMasterEntity> getAkunLeafDebet();
	
	public List<AkunMasterEntity> getAkunLeafKredit();
	
	
	/*
	 * Transaction Jurnal
	 */
	public void persist(TransactionJurnalUmumEntity transactionJurnal) throws Exception;
	
	public List<TransactionJurnalUmumEntity> getTransactionJurnals(Date start, Date end);

}